import axios from "axios";
import base from '../path';

const Instance = axios.create({
    // 移除baseURL配置，使用相对路径通过Vite代理
    timeout:5000
})

export default Instance; //导出一个axios实例，名为Instance

// 请求拦截器
Instance.interceptors.request.use(
  config => {
    const token = localStorage.getItem('token')?.trim();
    console.log('Token value after trim:', token);
    if (token) {
      config.headers.Authorization = `Bearer ${token.replace(/\s+/g, '')}`;
    }
    return config;
  },
  error => {
    return Promise.reject(error);
  }
);